#!/bin/sh

set -e

if [ $# -eq 1 ]; then
    day="$1"
else
    day=`date +%Y%m%d --date '-1 day'`
fi

if [ $day -gt '20121222' ]; then
    baseurl='http://10.5.12.160:50075/streamFile/dsap/resultdata/infostat/ZP_InfoJobHDFS/'
else
    baseurl='http://10.5.12.160:50075/streamFile/dsap/middata/infostat/ZP_InfoJobHDFS/'
fi


outfile=data/$day.txt
rm -f $outfile

toppart=60
i=0
while [ $i -lt $toppart ]; do
    part=part-r-`printf "%05d" $i`
    fullurl="${baseurl}${day}/${part}"

    # echo $fullurl
    wget $fullurl -qO- | egrep "^cate|^A" >>$outfile

    i=`expr $i + 1`
done

